package rentalstore;

import java.util.Enumeration;
import java.util.Vector;

/**
 * HtmlStatement
 *
 * @author Burgess Li
 * @createDate 2018/08/28 0:13
 */
public class HtmlStatement extends Statement {

    @Override
    protected String buildType() {
        return "HTML_STATEMENT";
    }

    String generateHeader(String title) {
        return "<H1>Rental Record for <EM>" + title + "</EM></H1><P>\n";
    }

    String generateDetails(Vector rentals) {
        StringBuilder result = new StringBuilder();
        Enumeration rentalsEnumeration = rentals.elements();
        while(rentalsEnumeration.hasMoreElements()){
            Rental each = (Rental) rentalsEnumeration.nextElement();
            //show figures for this rental
            result.append(each.getMovie().getTitle() + ": " + String.valueOf(each.computeAmount()) + "<BR>\n");
        }
        return result.toString();
    }

    String generateFooter(double totalAmount, double totalFrequentRenterPoints) {
        String result = "<P>You owe<EM>" + String.valueOf(totalAmount) + "</EM></P>\n";
        result += "On this rental you earned <EM>" + String.valueOf(totalFrequentRenterPoints) + "</EM> frequent renter points</P>";
        return result;
    }

}
